VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "tb_PIMTestData"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False

Dim AdoCnn1 As New ADODB.Connection



Public Function tb_IsvaildPID(ProductTypeID As String) As Boolean
    On Error GoTo ErrHandler:
    
    Dim cmd As New ADODB.Command
    If ProductTypeID <> "" Then
        Set cmd.ActiveConnection = AdoCnn1
        cmd.CommandText = "tb_IsProductType_ZTE"
        cmd.CommandType = adCmdStoredProc
        cmd.Parameters.Refresh
        cmd(1) = ProductTypeID
        cmd(2).direction = adParamOutput
        cmd.Execute
        
        If (cmd(2) = "1") Then
            tb_IsvaildPID = True
        Else
            tb_IsvaildPID = False
        End If
    Else
    End If
    Exit Function
    
ErrHandler:
    Exit Function
    
End Function



Public Function Read_ExcelAndWrite_Sql1(ByRef sFile1 As tb_result_DFL, ByRef sFile2() As tb_Param_DFL, ProductTypeID As String) As Boolean
    On Error GoTo ErrHandler:
    
    Dim i As Integer
    Dim currentid As Integer
    Dim strPsn As String
    Dim cmd As New ADODB.Command
    strPsn = sFile1.partcode
    
    If strPsn <> "" Then
        Set cmd.ActiveConnection = AdoCnn1
        cmd.CommandText = "tb_result_DFL_PIM_Insert"
        cmd.CommandType = adCmdStoredProc
        cmd.Parameters.Refresh
        cmd(1).direction = adParamOutput
        cmd(2) = strPsn
        cmd(3) = sFile1.testtime
        cmd(4) = sFile1.testperiod
        cmd(5) = sFile1.testequipid
        cmd(6) = sFile1.tfpid
        cmd(7) = sFile1.userid
        cmd(8) = sFile1.totalresult
        cmd(9) = sFile1.itemresult
        cmd(10) = sFile1.itemselinfo
        cmd(11) = sFile1.itemselcnt
        cmd(12) = sFile1.itemcnt
        cmd(13) = sFile1.remark
        cmd(14).direction = adParamOutput
        cmd.Execute
        currentid = cmd(1)
        strPsn = cmd(14)
        
        
        Set cmd.ActiveConnection = AdoCnn1
        cmd.CommandText = "tb_Param_DFL_Insert"
        cmd.CommandType = adCmdStoredProc
        For i = LBound(sFile2) To UBound(sFile2)
            cmd.Parameters.Refresh
            cmd(1) = currentid
            cmd(2) = strPsn
            cmd(3) = sFile2(i).testequipid
            cmd(4) = sFile2(i).UnitName
            cmd(5) = sFile2(i).testtime
            cmd(6) = sFile2(i).ParamName
            cmd(7) = sFile2(i).Res
            cmd(8) = sFile2(i).ResValue
            cmd(9) = sFile2(i).ResDesc
            cmd.Execute
        Next i
        
        Set cmd.ActiveConnection = AdoCnn1
        cmd.CommandText = "tb_DFL_Info_Insert"
        cmd.CommandType = adCmdStoredProc
        cmd.Parameters.Refresh
        cmd(1) = currentid
        cmd(2) = strPsn
        cmd(3) = sFile1.testtime
        cmd(4) = ProductTypeID
        cmd.Execute
        
    Else
    End If
    
    If Asc(strPsn) = 0 Then
        Read_ExcelAndWrite_Sql1 = False
    Else
        Read_ExcelAndWrite_Sql1 = True
    End If
    Exit Function
    
ErrHandler:
    If AdoCnn1.State = adStateOpen Then
        AdoCnn1.Close
    End If
    Set AdoCnn1 = Nothing
    Set cmd = Nothing
    
End Function

